﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ETA.Entity;
using ETA.IService;
using Ninject;
using NUnit.Framework;

namespace ETA.UnitTest
{
    public class QuestionTest
    {
        private static IQuestionService _IQuestionService { set; get; }

        [SetUp]
        public void Init()
        {
            IKernel kernel = new StandardKernel(new NinjectModuleBuild());
            _IQuestionService = kernel.Get<IQuestionService>();
        }


        [Test]
        public void TestAddQuestion()
        {
            var res = _IQuestionService.CreateQuestion(new CreateQuestionRequest
            {
                Question = new Entity.Question
                {
                    QuestionId = Guid.NewGuid() + "",
                    QuestionContent = "测试问题222",
                    ContactWay = "66849361@qq.com"
                }
            });
            Assert.True(res.Result.IsSuccess);
        }

        [Test]
        public void TestModifyQuestion()
        {
            var boolRes = false;
            int count = 0;
            var res = _IQuestionService.QueryQuestionList(new QueryQuestionRequest
            {
                Question = new Entity.Question
                {
                    QuestionId = "c7ee7344-e7eb-403a-b08a-2186bd33e3c1"
                }
            }, out count);

            var q = res.QuestionList.FirstOrDefault();
            q.QuestionContent = "哈哈测试";
            q.AnswerContent = "测试回答";
            var mRes = _IQuestionService.ModifyQuestion(new ModifyQuestionRequest { 
                 Question = q
            });
            boolRes = mRes.Result.IsSuccess;
            Assert.True(boolRes);
        }
        //e7fd8ea5-184a-45d1-a5e3-ce61c9ba7e22

    }
}
